package com.jpcc.vw.onlineRadio.http;

import android.graphics.Bitmap;
import android.os.RemoteException;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.cns.android.authentication.AppTokenInfo;
import com.cns.android.authentication.AppTokenManager;
import com.franmontiel.persistentcookiejar.ClearableCookieJar;
import com.franmontiel.persistentcookiejar.PersistentCookieJar;
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
import com.google.gson.Gson;
import com.jpcc.vw.onlineRadio.application.MusicApplication;
import com.jpcc.vw.onlineRadio.constants.Constants;
import com.jpcc.vw.onlineRadio.model.IRadio;
import com.jpcc.vw.onlineRadio.model.bean.ArtistInfo;
import com.jpcc.vw.onlineRadio.model.bean.BaseBean;
import com.jpcc.vw.onlineRadio.model.bean.CnsAccountInfoSelf;
import com.jpcc.vw.onlineRadio.model.bean.DownloadInfo;
import com.jpcc.vw.onlineRadio.model.bean.Lrc;
import com.jpcc.vw.onlineRadio.model.bean.OnlineMusicList;
import com.jpcc.vw.onlineRadio.model.bean.SearchMusic;
import com.jpcc.vw.onlineRadio.model.bean.Splash;
import com.jpcc.vw.onlineRadio.model.bean.XiMaLaYaOrderBean;
import com.jpcc.vw.onlineRadio.model.impl.RadioImpl;
import com.jpcc.vw.onlineRadio.utils.CommonSubscriber;
import com.jpcc.vw.onlineRadio.utils.ConfigReaderUtils;
import com.jpcc.vw.onlineRadio.utils.PreferenceUtils;
import com.jpcc.vw.onlineRadio.utils.SSLUtils;
import com.orhanobut.logger.Logger;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.BitmapCallback;
import com.zhy.http.okhttp.callback.FileCallBack;
import com.zhy.http.okhttp.callback.StringCallback;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import okhttp3.Call;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;

/**
 * Created by hzwangchenyan on 2017/2/8.
 */
public class HttpClient {
    static {
        SSLUtils.SSLParams sslParams = null;
        try {
            if (Constants.isRelease) {
                String certificate = AppTokenManager.getInstance(MusicApplication.GetInstance()).getHttpsCertificate();
                Logger.i("ServiceFactory----getHttpsCertificate--->>>" + certificate);
                String privateKey = AppTokenManager.getInstance(MusicApplication.GetInstance()).getHttpsPrivateKey();
                Logger.i("ServiceFactory----getprivateKey--->>>" + privateKey);
                if (!TextUtils.isEmpty(certificate) && !TextUtils.isEmpty(privateKey)) {
                    File file = new File(certificate);
                    if (file != null && file.exists()) {
                        try {
                            sslParams = SSLUtils.getSslSocketFactory(new FileInputStream(file),
                                    privateKey, SSLUtils.UnSafeTrustManager);
                        } catch (FileNotFoundException e) {
                            e.printStackTrace();
                        }
                    }
                }

//                InputStream inputStream=MusicApplication.GetInstance().getResources().getAssets().open("client_svw.bks");
//                sslParams = SSLUtils.getSslSocketFactory(inputStream,"123456", SSLUtils.UnSafeTrustManager);
            } else {
                InputStream inputStream = MusicApplication.GetInstance().getResources().getAssets().open("client.bks");
                sslParams = SSLUtils.getSslSocketFactory(inputStream, "123456", SSLUtils.UnSafeTrustManager);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }

        ClearableCookieJar cookieJar1 = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(MusicApplication.GetInstance()));


        if (Constants.isRelease) {
            OkHttpClient okHttpClient = new OkHttpClient.Builder()
                    .connectTimeout(10, TimeUnit.SECONDS)
                    .readTimeout(10, TimeUnit.SECONDS)
                    .writeTimeout(10, TimeUnit.SECONDS)
//                    .addInterceptor(new com.jpcc.vw.onlineRadio.http.HttpInterceptor())
                    .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                    .hostnameVerifier(SSLUtils.UnSafeHostnameVerifier)
                    .cookieJar(cookieJar1)
                    .build();
            OkHttpUtils.initClient(okHttpClient);
        } else {
            OkHttpClient okHttpClient = new OkHttpClient.Builder()
                    .connectTimeout(10, TimeUnit.SECONDS)
                    .readTimeout(10, TimeUnit.SECONDS)
                    .writeTimeout(10, TimeUnit.SECONDS)
                    .addInterceptor(new com.jpcc.vw.onlineRadio.http.HttpInterceptor())
                    .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                    .hostnameVerifier(SSLUtils.UnSafeHostnameVerifier)
                    .cookieJar(cookieJar1)
                    .build();
            OkHttpUtils.initClient(okHttpClient);
        }
    }


    private static void initClient() {
    }


    /**
     * 通用的提交json的网络请求方法
     *
     * @param jsonString
     */
    public static void CancelUserFavourite(String jsonString, StringCallback callback) {
        Logger.i("CancelUserFavourite-->" + jsonString);
        IRadio model = new RadioImpl();
        model.CancelUserFavourite(jsonString).subscribe(new CommonSubscriber<BaseBean>() {
            @Override
            public void onSuccess(BaseBean response) {
                if (callback != null) {
                    String json = new Gson().toJson(response);
                    callback.onResponse(json, 0);
                }
            }

            @Override
            public void onFailure(BaseBean response) {
                if (callback != null) {
                    callback.onError(null, new Exception("CancelUserFavourite error"), 0);
                }
            }
        });


//        if (Constants.isRelease) {
//            AppTokenInfo tokenInfo=new Gson().fromJson(PreferenceUtils.GetTokenInfo(),AppTokenInfo.class);
//            String url="https://tmuat.cmsp.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if(tokenInfo!=null&&!TextUtils.isEmpty(tokenInfo.getUrl())){
//                url=tokenInfo.getUrl();
//            }
////            url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            File file = new File("/mnt/nfs/onlineapplication.conf");
//            if (file.exists()) {
//                Logger.i("file exists-->"+file.getAbsolutePath());
//                String Authorization = "";
//                AppTokenInfo appTokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//                if (appTokenInfo == null) {
//                    Authorization = "";
//                } else {
//                    Authorization = appTokenInfo.getToken();
//                }
//                Logger.i("Authorization-->"+Authorization);
//                String TraceId = "";
//                String uuid = UUID.randomUUID().toString();
//                TraceId = TraceId + uuid;
//                Logger.i("TraceId 1-->"+TraceId);
//                CnsAccountInfoSelf accountInfo = new Gson().fromJson(PreferenceUtils.GetAccountInfo(), CnsAccountInfoSelf.class);
//                if (accountInfo == null) {
//                    TraceId = TraceId+"_" + ConfigReaderUtils.readUidFromConfig();
//                    Logger.i("TraceId 2-->"+TraceId);
//                } else {
//                    if ((accountInfo.getType() == 2 || accountInfo.getType() == 3)) {
//                        TraceId = TraceId+"_" + "sc";
//                    } else {
//                        TraceId = TraceId+"_" + accountInfo.getId();
//                    }
//                    Logger.i("TraceId 3-->"+TraceId);
//                }
//                String DeviceId = "";
//                if (TextUtils.isEmpty(PreferenceUtils.GetDeviceId())) {
//                    TraceId = TraceId+"_" + ConfigReaderUtils.readDidFromConfig();
//                    DeviceId = ConfigReaderUtils.readDidFromConfig();
//                    Logger.i("DeviceId 1-->"+DeviceId);
//                } else {
//                    TraceId = TraceId + "_" + PreferenceUtils.GetDeviceId();
//                    DeviceId = PreferenceUtils.GetDeviceId();
//                    Logger.i("DeviceId 2-->"+DeviceId);
//                }
//                TraceId = TraceId+"_" + System.currentTimeMillis();
//                Logger.i("TraceId 4-->"+TraceId);
//                OkHttpUtils.postString().url(url+"collection/cancel")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer "+Authorization)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", TraceId)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", ("CNS3_"+DeviceId+"_v1.0.1"+"_v0.0.1").replace(" ",""))
//                        .addHeader("clientOsType","2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            } else {
//                OkHttpUtils.postString().url(url+"collection/cancel")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer "+Constants.DEAFAULTOKEN)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", Constants.DEFAULT_DID)
//                        .addHeader("clientOsType","2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            }
//
//        } else {
////            String url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            OkHttpUtils.postString().url(Constants.BASE_URL+"collection/cancel")
//                    .content(jsonString)
//                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("Authorization", "bearer "+Constants.DEAFAULTOKEN)
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                    .addHeader("Accept-Language", "zh-cn")
//                    .addHeader("Accept", "application/json; charset=utf-8")
//                    .addHeader("Did", Constants.DEFAULT_DID)
//                    .addHeader("clientOsType","2")
//                    .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                    .build()
//                    .execute(callback);
//        }
    }

    public static void AddUserFavourite(String jsonString, StringCallback callback) {
        Logger.i("AddUserFavourite-->" + jsonString);
        IRadio model = new RadioImpl();


//        if (Constants.isRelease) {
//            File file = new File("/mnt/nfs/onlineapplication.conf");
//            AppTokenInfo tokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//            String url = "https://tmuat.cmsp.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (tokenInfo != null && !TextUtils.isEmpty(tokenInfo.getUrl())) {
//                url = tokenInfo.getUrl();
//            }
////            url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (file.exists()) {
//                Logger.i("file exists-->" + file.getAbsolutePath());
//                String Authorization = "";
//                AppTokenInfo appTokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//                if (appTokenInfo == null) {
//                    Authorization = "";
//                } else {
//                    Authorization = appTokenInfo.getToken();
//                }
//                Logger.i("Authorization-->" + Authorization);
//                String TraceId = "";
//                String uuid = UUID.randomUUID().toString();
//                TraceId = TraceId + uuid;
//                Logger.i("TraceId 1-->" + TraceId);
//                CnsAccountInfoSelf accountInfo = new Gson().fromJson(PreferenceUtils.GetAccountInfo(), CnsAccountInfoSelf.class);
//                if (accountInfo == null) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readUidFromConfig();
//                    Logger.i("TraceId 2-->" + TraceId);
//                } else {
//                    if ((accountInfo.getType() == 2 || accountInfo.getType() == 3)) {
//                        TraceId = TraceId + "_" + "sc";
//                    } else {
//                        TraceId = TraceId + "_" + accountInfo.getId();
//                    }
//                    Logger.i("TraceId 3-->" + TraceId);
//                }
//                String DeviceId = "";
//                if (TextUtils.isEmpty(PreferenceUtils.GetDeviceId())) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readDidFromConfig();
//                    DeviceId = ConfigReaderUtils.readDidFromConfig();
//                    Logger.i("DeviceId 1-->" + DeviceId);
//                } else {
//                    TraceId = TraceId + "_" + PreferenceUtils.GetDeviceId();
//                    DeviceId = PreferenceUtils.GetDeviceId();
//                    Logger.i("DeviceId 2-->" + DeviceId);
//                }
//                TraceId = TraceId + "_" + System.currentTimeMillis();
//                Logger.i("TraceId 4-->" + TraceId);
//                OkHttpUtils.postString().url(url + "collection/add")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Authorization)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", TraceId)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", ("CNS3_" + DeviceId + "_v1.0.1" + "_v0.0.1").replace(" ", ""))
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            } else {
//                OkHttpUtils.postString().url(url + "collection/add")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", Constants.DEFAULT_DID)
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            }
//
//        } else {
////            String url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            OkHttpUtils.postString().url(Constants.BASE_URL + "collection/add")
//                    .content(jsonString)
//                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                    .addHeader("Accept-Language", "zh-cn")
//                    .addHeader("Accept", "application/json; charset=utf-8")
//                    .addHeader("Did", Constants.DEFAULT_DID)
//                    .addHeader("clientOsType", "2")
//                    .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                    .build()
//                    .execute(callback);
//        }

        model.AddUserFavourite(jsonString).subscribe(new CommonSubscriber<BaseBean>() {
            @Override
            public void onSuccess(BaseBean response) {
                String json = new Gson().toJson(response);
                if (callback != null) {
                    callback.onResponse(json, 0);
                }
            }

            @Override
            public void onFailure(BaseBean response) {
                if (callback != null) {
                    callback.onError(null, new Exception("AddUserFavourite error"), 0);
                }
            }
        });


    }


//    public static void AddUserHistory(String jsonString, StringCallback callback){
//        Logger.i("AddUserHistory-->"+jsonString);
//        initClient();
//        if (Constants.isRelease) {
//            File file = new File("/mnt/nfs/onlineapplication.conf");
//            AppTokenInfo tokenInfo=new Gson().fromJson(PreferenceUtils.GetTokenInfo(),AppTokenInfo.class);
//            String url="https://tmuat.cmsp.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if(tokenInfo!=null&&!TextUtils.isEmpty(tokenInfo.getUrl())){
//                url=tokenInfo.getUrl();
//            }
////            url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (file.exists()) {
//                Logger.i("file exists-->"+file.getAbsolutePath());
//                String Authorization = "";
//                AppTokenInfo appTokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//                if (appTokenInfo == null) {
//                    Authorization = "";
//                } else {
//                    Authorization = appTokenInfo.getToken();
//                }
//                Logger.i("Authorization-->"+Authorization);
//                String TraceId = "";
//                String uuid = UUID.randomUUID().toString();
//                TraceId = TraceId + uuid;
//                Logger.i("TraceId 1-->"+TraceId);
//                CnsAccountInfoSelf accountInfo = new Gson().fromJson(PreferenceUtils.GetAccountInfo(), CnsAccountInfoSelf.class);
//                if (accountInfo == null) {
//                    TraceId = TraceId+"_" + ConfigReaderUtils.readUidFromConfig();
//                    Logger.i("TraceId 2-->"+TraceId);
//                } else {
//                    if ((accountInfo.getType() == 2 || accountInfo.getType() == 3)) {
//                        TraceId = TraceId+"_" + "sc";
//                    } else {
//                        TraceId = TraceId+"_" + accountInfo.getId();
//                    }
//                    Logger.i("TraceId 3-->"+TraceId);
//                }
//                String DeviceId = "";
//                if (TextUtils.isEmpty(PreferenceUtils.GetDeviceId())) {
//                    TraceId = TraceId+"_" + ConfigReaderUtils.readDidFromConfig();
//                    DeviceId = ConfigReaderUtils.readDidFromConfig();
//                    Logger.i("DeviceId 1-->"+DeviceId);
//                } else {
//                    TraceId = TraceId + "_" + PreferenceUtils.GetDeviceId();
//                    DeviceId = PreferenceUtils.GetDeviceId();
//                    Logger.i("DeviceId 2-->"+DeviceId);
//                }
//                TraceId = TraceId+"_" + System.currentTimeMillis();
//                Logger.i("TraceId 4-->"+TraceId);
//                OkHttpUtils.postString().url(url+"playHistory/add")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer "+Authorization)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", TraceId)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", ("CNS3_"+DeviceId+"_v1.0.1"+"_v0.0.1").replace(" ",""))
//                        .addHeader("clientOsType","2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            } else {
//                OkHttpUtils.postString().url(url+"playHistory/add")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer "+Constants.DEAFAULTOKEN)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", Constants.DEFAULT_DID)
//                        .addHeader("clientOsType","2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            }
//
//        } else {
////            String url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            OkHttpUtils.postString().url(Constants.BASE_URL+"playHistory/add")
//                    .content(jsonString)
//                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("Authorization", "bearer "+Constants.DEAFAULTOKEN)
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                    .addHeader("Accept-Language", "zh-cn")
//                    .addHeader("Accept", "application/json; charset=utf-8")
//                    .addHeader("Did", Constants.DEFAULT_DID)
//                    .addHeader("clientOsType","2")
//                    .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                    .build()
//                    .execute(callback);
//        }
//    }

    public static void SyncSearchHistory(String jsonString, StringCallback callback) {
        Logger.i("SyncSearchHistory-->" + jsonString);
//        if (Constants.isRelease) {
//            File file = new File("/mnt/nfs/onlineapplication.conf");
//            AppTokenInfo tokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//            String url = "https://tmuat.cmsp.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (tokenInfo != null && !TextUtils.isEmpty(tokenInfo.getUrl())) {
//                url = tokenInfo.getUrl();
//            }
////            url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (file.exists()) {
//                Logger.i("file exists-->" + file.getAbsolutePath());
//                String Authorization = "";
//                AppTokenInfo appTokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//                if (appTokenInfo == null) {
//                    Authorization = "";
//                } else {
//                    Authorization = appTokenInfo.getToken();
//                }
//                Logger.i("Authorization-->" + Authorization);
//                String TraceId = "";
//                String uuid = UUID.randomUUID().toString();
//                TraceId = TraceId + uuid;
//                Logger.i("TraceId 1-->" + TraceId);
//                CnsAccountInfoSelf accountInfo = new Gson().fromJson(PreferenceUtils.GetAccountInfo(), CnsAccountInfoSelf.class);
//                if (accountInfo == null) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readUidFromConfig();
//                    Logger.i("TraceId 2-->" + TraceId);
//                } else {
//                    if ((accountInfo.getType() == 2 || accountInfo.getType() == 3)) {
//                        TraceId = TraceId + "_" + "sc";
//                    } else {
//                        TraceId = TraceId + "_" + accountInfo.getId();
//                    }
//                    Logger.i("TraceId 3-->" + TraceId);
//                }
//                String DeviceId = "";
//                if (TextUtils.isEmpty(PreferenceUtils.GetDeviceId())) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readDidFromConfig();
//                    DeviceId = ConfigReaderUtils.readDidFromConfig();
//                    Logger.i("DeviceId 1-->" + DeviceId);
//                } else {
//                    TraceId = TraceId + "_" + PreferenceUtils.GetDeviceId();
//                    DeviceId = PreferenceUtils.GetDeviceId();
//                    Logger.i("DeviceId 2-->" + DeviceId);
//                }
//                TraceId = TraceId + "_" + System.currentTimeMillis();
//                Logger.i("TraceId 4-->" + TraceId);
//                OkHttpUtils.postString().url(url + "searchHistory/sync")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Authorization)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", TraceId)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", ("CNS3_" + DeviceId + "_v1.0.1" + "_v0.0.1").replace(" ", ""))
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            } else {
//                OkHttpUtils.postString().url(url + "searchHistory/sync")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", Constants.DEFAULT_DID)
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            }
//
//        } else {
////            String url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            OkHttpUtils.postString().url(Constants.BASE_URL + "searchHistory/sync")
//                    .content(jsonString)
//                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                    .addHeader("Accept-Language", "zh-cn")
//                    .addHeader("Accept", "application/json; charset=utf-8")
//                    .addHeader("Did", Constants.DEFAULT_DID)
//                    .addHeader("clientOsType", "2")
//                    .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                    .build()
//                    .execute(callback);
//        }

        IRadio model = new RadioImpl();
        model.SyncSearchHistory(jsonString).subscribe(new CommonSubscriber<BaseBean>() {
            @Override
            public void onSuccess(BaseBean response) {
                if (callback != null) {
                    String json = new Gson().toJson(response);
                    callback.onResponse(json, 0);
                }
            }

            @Override
            public void onFailure(BaseBean response) {
                if (callback != null) {
                    callback.onError(null, new Exception("SyncSearchHistory error"), 0);
                }
            }
        });


    }


    public static void SyncPlayHistory(String jsonString, StringCallback callback) {
        Logger.i("SyncPlayHistory-->" + jsonString);
//        if (Constants.isRelease) {
//            AppTokenInfo tokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//            String url = "https://tmuat.cmsp.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (tokenInfo != null && !TextUtils.isEmpty(tokenInfo.getUrl())) {
//                url = tokenInfo.getUrl();
//            }
////            url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            File file = new File("/mnt/nfs/onlineapplication.conf");
//            if (file.exists()) {
//                Logger.i("file exists-->" + file.getAbsolutePath());
//                String Authorization = "";
//                AppTokenInfo appTokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//                if (appTokenInfo == null) {
//                    Authorization = "";
//                } else {
//                    Authorization = appTokenInfo.getToken();
//                }
//                Logger.i("Authorization-->" + Authorization);
//                String TraceId = "";
//                String uuid = UUID.randomUUID().toString();
//                TraceId = TraceId + uuid;
//                Logger.i("TraceId 1-->" + TraceId);
//                CnsAccountInfoSelf accountInfo = new Gson().fromJson(PreferenceUtils.GetAccountInfo(), CnsAccountInfoSelf.class);
//                if (accountInfo == null) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readUidFromConfig();
//                    Logger.i("TraceId 2-->" + TraceId);
//                } else {
//                    if ((accountInfo.getType() == 2 || accountInfo.getType() == 3)) {
//                        TraceId = TraceId + "_" + "sc";
//                    } else {
//                        TraceId = TraceId + "_" + accountInfo.getId();
//                    }
//                    Logger.i("TraceId 3-->" + TraceId);
//                }
//                String DeviceId = "";
//                if (TextUtils.isEmpty(PreferenceUtils.GetDeviceId())) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readDidFromConfig();
//                    DeviceId = ConfigReaderUtils.readDidFromConfig();
//                    Logger.i("DeviceId 1-->" + DeviceId);
//                } else {
//                    TraceId = TraceId + "_" + PreferenceUtils.GetDeviceId();
//                    DeviceId = PreferenceUtils.GetDeviceId();
//                    Logger.i("DeviceId 2-->" + DeviceId);
//                }
//                TraceId = TraceId + "_" + System.currentTimeMillis();
//                Logger.i("TraceId 4-->" + TraceId);
//                OkHttpUtils.postString().url(url + "playHistory/add")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Authorization)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", TraceId)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", ("CNS3_" + DeviceId + "_v1.0.1" + "_v0.0.1").replace(" ", ""))
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            } else {
//                OkHttpUtils.postString().url(url + "playHistory/add")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", Constants.DEFAULT_DID)
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            }
//
//        } else {
////            String url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            OkHttpUtils.postString().url(Constants.BASE_URL + "playHistory/add")
//                    .content(jsonString)
//                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                    .addHeader("Accept-Language", "zh-cn")
//                    .addHeader("Accept", "application/json; charset=utf-8")
//                    .addHeader("Did", Constants.DEFAULT_DID)
//                    .addHeader("clientOsType", "2")
//                    .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                    .build()
//                    .execute(callback);
//        }
        IRadio model = new RadioImpl();
        model.SyncPlayHistory(jsonString).subscribe(new CommonSubscriber<BaseBean>() {
            @Override
            public void onSuccess(BaseBean response) {
                String json = new Gson().toJson(response);
                if (callback != null) {
                    callback.onResponse(json, 0);
                }
            }

            @Override
            public void onFailure(BaseBean response) {
                if (callback != null) {
                    callback.onError(null, new Exception("SyncPlayHistory error"), 0);
                }
            }
        });


    }

    public static void DeletePlayHistory(String jsonString, StringCallback callback) {
        Logger.i("DeletePlayHistory-->" + jsonString);
//        if (Constants.isRelease) {
//            AppTokenInfo tokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//            String url = "https://tmuat.cmsp.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (tokenInfo != null && !TextUtils.isEmpty(tokenInfo.getUrl())) {
//                url = tokenInfo.getUrl();
//            }
////            url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            File file = new File("/mnt/nfs/onlineapplication.conf");
//            if (file.exists()) {
//                Logger.i("file exists-->" + file.getAbsolutePath());
//                String Authorization = "";
//                AppTokenInfo appTokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//                if (appTokenInfo == null) {
//                    Authorization = "";
//                } else {
//                    Authorization = appTokenInfo.getToken();
//                }
//                Logger.i("Authorization-->" + Authorization);
//                String TraceId = "";
//                String uuid = UUID.randomUUID().toString();
//                TraceId = TraceId + uuid;
//                Logger.i("TraceId 1-->" + TraceId);
//                CnsAccountInfoSelf accountInfo = new Gson().fromJson(PreferenceUtils.GetAccountInfo(), CnsAccountInfoSelf.class);
//                if (accountInfo == null) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readUidFromConfig();
//                    Logger.i("TraceId 2-->" + TraceId);
//                } else {
//                    if ((accountInfo.getType() == 2 || accountInfo.getType() == 3)) {
//                        TraceId = TraceId + "_" + "sc";
//                    } else {
//                        TraceId = TraceId + "_" + accountInfo.getId();
//                    }
//                    Logger.i("TraceId 3-->" + TraceId);
//                }
//                String DeviceId = "";
//                if (TextUtils.isEmpty(PreferenceUtils.GetDeviceId())) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readDidFromConfig();
//                    DeviceId = ConfigReaderUtils.readDidFromConfig();
//                    Logger.i("DeviceId 1-->" + DeviceId);
//                } else {
//                    TraceId = TraceId + "_" + PreferenceUtils.GetDeviceId();
//                    DeviceId = PreferenceUtils.GetDeviceId();
//                    Logger.i("DeviceId 2-->" + DeviceId);
//                }
//                TraceId = TraceId + "_" + System.currentTimeMillis();
//                Logger.i("TraceId 4-->" + TraceId);
//                OkHttpUtils.postString().url(url + "playHistory/delete")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Authorization)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", TraceId)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", ("CNS3_" + DeviceId + "_v1.0.1" + "_v0.0.1").replace(" ", ""))
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            } else {
//                OkHttpUtils.postString().url(url + "playHistory/delete")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", Constants.DEFAULT_DID)
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            }
//
//        } else {
//            Logger.i("DeletePlayHistory-->" + Constants.DEAFAULTOKEN);
//            Logger.i("placeOrder url-->" + Constants.BASE_URL);
////            String url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            OkHttpUtils.postString().url(Constants.BASE_URL + "playHistory/delete")
//                    .content(jsonString)
//                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                    .addHeader("Accept-Language", "zh-cn")
//                    .addHeader("Accept", "application/json; charset=utf-8")
//                    .addHeader("Did", Constants.DEFAULT_DID)
//                    .addHeader("clientOsType", "2")
//                    .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                    .build()
//                    .execute(callback);
//        }


        IRadio model = new RadioImpl();
        model.DeletePlayHistory(jsonString).subscribe(new CommonSubscriber<BaseBean>() {
            @Override
            public void onSuccess(BaseBean response) {
                if (callback != null) {
                    String json = new Gson().toJson(response);
                    callback.onResponse(json, 0);
                }
            }

            @Override
            public void onFailure(BaseBean response) {
                if (callback != null) {
                    callback.onError(null, new Exception("DeletePlayHistory error"), 0);
                }
            }
        });
    }


    public static void GetDailyRecommendation(StringCallback callback) {
        OkHttpUtils.get().url(Constants.BASE_URL + "recommend").addParams("displayCount", 3 + "").build().execute(callback);
//                .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                .build()
//                .execute(callback);
    }


    public static void PlaceOrder(String jsonString, StringCallback callback) {
        Logger.i("PlaceOrder-->" + jsonString);
//        if (Constants.isRelease) {
//            File file = new File("/mnt/nfs/onlineapplication.conf");
//            AppTokenInfo tokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//            String url = "https://tmuat.cmsp.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (tokenInfo != null && !TextUtils.isEmpty(tokenInfo.getUrl())) {
//                url = tokenInfo.getUrl();
//            }
////            url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            if (file.exists()) {
//                Logger.i("file exists-->" + file.getAbsolutePath());
//                String Authorization = "";
//                AppTokenInfo appTokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
//                if (appTokenInfo == null) {
//                    Authorization = "";
//                } else {
//                    Authorization = appTokenInfo.getToken();
//                }
//                Logger.i("Authorization-->" + Authorization);
//                String TraceId = "";
//                String uuid = UUID.randomUUID().toString();
//                TraceId = TraceId + uuid;
//                Logger.i("TraceId 1-->" + TraceId);
//                CnsAccountInfoSelf accountInfo = new Gson().fromJson(PreferenceUtils.GetAccountInfo(), CnsAccountInfoSelf.class);
//                if (accountInfo == null) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readUidFromConfig();
//                    Logger.i("TraceId 2-->" + TraceId);
//                } else {
//                    if ((accountInfo.getType() == 2 || accountInfo.getType() == 3)) {
//                        TraceId = TraceId + "_" + "sc";
//                    } else {
//                        TraceId = TraceId + "_" + accountInfo.getId();
//                    }
//                    Logger.i("TraceId 3-->" + TraceId);
//                }
//                String DeviceId = "";
//                if (TextUtils.isEmpty(PreferenceUtils.GetDeviceId())) {
//                    TraceId = TraceId + "_" + ConfigReaderUtils.readDidFromConfig();
//                    DeviceId = ConfigReaderUtils.readDidFromConfig();
//                    Logger.i("DeviceId 1-->" + DeviceId);
//                } else {
//                    TraceId = TraceId + "_" + PreferenceUtils.GetDeviceId();
//                    DeviceId = PreferenceUtils.GetDeviceId();
//                    Logger.i("DeviceId 2-->" + DeviceId);
//                }
//                TraceId = TraceId + "_" + System.currentTimeMillis();
//                Logger.i("TraceId 4-->" + TraceId);
//                OkHttpUtils.postString().url(url + "openPay/placeOrder")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", Authorization)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", TraceId)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", ("CNS3_" + DeviceId + "_v1.0.1" + "_v0.0.1").replace(" ", ""))
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            } else {
//                OkHttpUtils.postString().url(url + "openPay/placeOrder")
//                        .content(jsonString)
//                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                        .addHeader("Content-Type", "application/json")
//                        .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                        .addHeader("Accept-Language", "zh-cn")
//                        .addHeader("Accept", "application/json; charset=utf-8")
//                        .addHeader("Did", Constants.DEFAULT_DID)
//                        .addHeader("clientOsType", "2")
//                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                        .build()
//                        .execute(callback);
//            }
//
//        } else {
////            String url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
//            OkHttpUtils.postString().url(Constants.BASE_URL + "openPay/placeOrder")
//                    .content(jsonString)
//                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
//                    .addHeader("Content-Type", "application/json")
//                    .addHeader("TraceId", Constants.DEFAULT_TRACEID)
//                    .addHeader("Accept-Language", "zh-cn")
//                    .addHeader("Accept", "application/json; charset=utf-8")
//                    .addHeader("Did", Constants.DEFAULT_DID)
//                    .addHeader("clientOsType", "2")
//                    .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
//                    .build()
//                    .execute(callback);
//        }


        IRadio model = new RadioImpl();
        model.PlaceOrder(jsonString).subscribe(new CommonSubscriber<XiMaLaYaOrderBean>() {
            @Override
            public void onSuccess(XiMaLaYaOrderBean response) {
                if (callback != null) {
                    String json = new Gson().toJson(response);
                    callback.onResponse(json, 0);
                }
            }

            @Override
            public void onFailure(BaseBean response) {
                if (callback != null) {
                    String json = new Gson().toJson(response);
                    callback.onResponse(json, 0);
                }
            }
        });
    }


    public static void ConfirmOrder(String jsonString, StringCallback callback) {
        Logger.i("ConfirmOrder-->" + jsonString);
        initClient();
        if (Constants.isRelease) {
            File file = new File("/mnt/nfs/onlineapplication.conf");
            AppTokenInfo tokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
            String url = "https://tmuat.cmsp.faw-vw.com/test-access/tm/mos/radio/api/v1/";
            if (tokenInfo != null && !TextUtils.isEmpty(tokenInfo.getUrl())) {
                url = tokenInfo.getUrl();
            }
//            url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
            if (file.exists()) {
                Logger.i("file exists-->" + file.getAbsolutePath());
                String Authorization = "";
                AppTokenInfo appTokenInfo = new Gson().fromJson(PreferenceUtils.GetTokenInfo(), AppTokenInfo.class);
                if (appTokenInfo == null) {
                    Authorization = "";
                } else {
                    Authorization = appTokenInfo.getToken();
                }
                Logger.i("Authorization-->" + Authorization);
                String TraceId = "";
                String uuid = UUID.randomUUID().toString();
                TraceId = TraceId + uuid;
                Logger.i("TraceId 1-->" + TraceId);
                CnsAccountInfoSelf accountInfo = new Gson().fromJson(PreferenceUtils.GetAccountInfo(), CnsAccountInfoSelf.class);
                if (accountInfo == null) {
                    TraceId = TraceId + "_" + ConfigReaderUtils.readUidFromConfig();
                    Logger.i("TraceId 2-->" + TraceId);
                } else {
                    if ((accountInfo.getType() == 2 || accountInfo.getType() == 3)) {
                        TraceId = TraceId + "_" + "sc";
                    } else {
                        TraceId = TraceId + "_" + accountInfo.getId();
                    }
                    Logger.i("TraceId 3-->" + TraceId);
                }
                String DeviceId = "";
                if (TextUtils.isEmpty(PreferenceUtils.GetDeviceId())) {
                    TraceId = TraceId + "_" + ConfigReaderUtils.readDidFromConfig();
                    DeviceId = ConfigReaderUtils.readDidFromConfig();
                    Logger.i("DeviceId 1-->" + DeviceId);
                } else {
                    TraceId = TraceId + "_" + PreferenceUtils.GetDeviceId();
                    DeviceId = PreferenceUtils.GetDeviceId();
                    Logger.i("DeviceId 2-->" + DeviceId);
                }
                TraceId = TraceId + "_" + System.currentTimeMillis();
                Logger.i("TraceId 4-->" + TraceId);
                OkHttpUtils.postString().url(url + "openPay/confirmOrder")
                        .content(jsonString)
                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
                        .addHeader("Content-Type", "application/json")
                        .addHeader("Authorization", Authorization)
                        .addHeader("Content-Type", "application/json")
                        .addHeader("TraceId", TraceId)
                        .addHeader("Accept-Language", "zh-cn")
                        .addHeader("Accept", "application/json; charset=utf-8")
                        .addHeader("Did", ("CNS3_" + DeviceId + "_v1.0.1" + "_v0.0.1").replace(" ", ""))
                        .addHeader("clientOsType", "2")
                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
                        .build()
                        .execute(callback);
            } else {
                OkHttpUtils.postString().url(url + "openPay/confirmOrder")
                        .content(jsonString)
                        .mediaType(MediaType.parse("application/json; charset=utf-8"))
                        .addHeader("Content-Type", "application/json")
                        .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
                        .addHeader("Content-Type", "application/json")
                        .addHeader("TraceId", Constants.DEFAULT_TRACEID)
                        .addHeader("Accept-Language", "zh-cn")
                        .addHeader("Accept", "application/json; charset=utf-8")
                        .addHeader("Did", Constants.DEFAULT_DID)
                        .addHeader("clientOsType", "2")
                        .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
                        .build()
                        .execute(callback);
            }

        } else {
//            String url="https://hu-uat.mosc.faw-vw.com/test-access/tm/mos/radio/api/v1/";
            OkHttpUtils.postString().url(Constants.BASE_URL + "openPay/confirmOrder")
                    .content(jsonString)
                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
                    .addHeader("Content-Type", "application/json")
                    .addHeader("Authorization", "bearer " + Constants.DEAFAULTOKEN)
                    .addHeader("Content-Type", "application/json")
                    .addHeader("TraceId", Constants.DEFAULT_TRACEID)
                    .addHeader("Accept-Language", "zh-cn")
                    .addHeader("Accept", "application/json; charset=utf-8")
                    .addHeader("Did", Constants.DEFAULT_DID)
                    .addHeader("clientOsType", "2")
                    .addHeader("Timestamp", String.valueOf(System.currentTimeMillis()))
                    .build()
                    .execute(callback);
        }
    }
}
